/*******************************上传功能专用**********************************/
function OnUploadCompleted(err,url,file,message){
	if(url==''){alert('请正确选择文件上传!\n'+message);return};
    if(err==0){
    	alert('上传成功('+url+')!!       ');
        TM.BrowserFile();
    }else{
    	alert('上传失败!!\n\n原因:'+message+'.      ');
	}
}
var debug = true;
var activeItem=null;
var activeIndex = -1;

/* 模块管理类 */
var TM =
{
	/*
	--templates[] 
	id: 当前查块的ID值 , div:层ID ,name: 模块名称 , page:页码 ,query:查询过滤的条件 , pname:父级模块的名称
	*/
	ver : '1.09.0203',
	templates : [] , 
	activeIndex : -1,
	activeItem : null,
	oPopup : window.createPopup(),
	/* 验证码 */
	CheckCode :null,
	/* 是否验证 */
	IsCheckedCode : false,
	IsEdit : false,
	_FileDialog : null,
	_dialog_ : null,
	IsQueryed : false,
	IsAlert : true,
	activeQuery : null,
	activeDiv : 'divContent',
	queryDiv : 'divQuery',
	tmpDiv : 'divTemp',
	tmpWidth : 500,
	tmpHeight :300,
	tWindows : [],
	oFCKeditor : null,
	selectObj : {text:null,value:null},
	/* 页面登录　*/
	chkAdminLogin : function(/*String|Object*/userId,/*String|Object*/pwdId,/*String*/vCode,/*String*/toUrl){
		if(!toUrl) toUrl= '/default.html';
		if(!userId||!pwdId)return;
		var _alert = _window.Open('<img src="/images/default/loading.gif"/>','系统登录中,请稍候...','ismodal=1,width=240,class=NOKIA,resize=no');
		userId = Object.isString(userId)?$(userId)['value']:userId;
		pwdId = Object.isString(pwdId)?$(pwdId)['value']:pwdId;
		vCode = Object.isString(vCode)?(($(vCode)==null)?'':$(vCode)['value']):vCode;
		var rtnValue  = false;
		if(userId.length<3||pwdId.length<3){
			alert('对不起！用户名及密码至少3位！！');
		}else{
		var q= 'mLoginUid='+userId+'&mLoginPwd='+pwdId+'&vCode='+vCode;
		new Ajax.Request('/httpchklogin.html',
										{
											asynchronous:false,
											parameters: q ,
											method: 'post',
											onComplete:function(r){
												var text = r.responseText;
												if(text.split(",")[0]==0){
													rtnValue = true;
													if(toUrl==null){
														location.href=document.referer?document.referer:'/my/default.html';
													}else location.href=toUrl;
													_alert = _window.Open('<img src="/images/default/loading.gif"/>','登录成功！转向中,请稍候...','ismodal=1,width=240,class=NOKIA,resize=no');
												}else if(text.split(",")[0]==103){
													if($('vCodeLine')) Element.show('vCodeLine');
													rtnValue = false;
													alert(text.split(",")[1]);
												}else{
													rtnValue = false;
													alert(text.split(",")[1]);
												}
											}
										});
		}
		_alert.Hidden();
		return rtnValue;
	},
	/*******************************页面事件处理**********************************/
	onClick : function(){
		var el = event.srcElement;
		if(el!=null)
			if(el.className!='more')
				if(TM.$('popMenu')!=null)
					TM.$('popMenu').style.display='none';
	},
	/*********************打开选择窗口************************/
	openSelect : function(sName,title,txtId,valueId,Wid){
		if(this.$(txtId)) this.selectObj.text = this.$(txtId);
		if(this.$(valueId)) this.selectObj.value = this.$(valueId);
		var title = title;
		var sQuery = 'values='+this.$(valueId).value;
		var ajax = new Ajax.Request('/xmlhttp.html',{
																parameters: 'f='+encodeURI(sName)+'&'+sQuery ,method: 'get',evalJS: true,
																onComplete: function(r) {TM.open(r.responseText,title,Wid);}});
	},
	contextMenu : function(evt,query,w,h){
		var left = Event.pointerX(evt);
		var top = Event.pointerY(evt);
		var ajax = new Ajax.Request('/xmlhttp.html',{
					parameters: query,method: 'get',evalJS: true,
					onComplete: function(r) {
						if(TM.oPopup.document.styleSheets.length==0)
							TM.oPopup.document.createStyleSheet('/css/v2/pop.css?'+Math.random());
						TM.oPopup.document.body.innerHTML=r.responseText;
						TM.oPopup.show(left, top, 88||w, 88||h, window.document.body);
					}});
		return false;
	},
	closePopup : function(){
		TM.oPopup.hide();
	},
	
	open : function(sContent,ops){
		var w = (ops.width==null)?300:ops.width
		var h = (ops.height==null)?200:ops.height
		var sName = sContent.substring(5);
		var type = sContent.substring(0,5);
		var args =(ops.args==null)?'':ops.args;
		var title = (ops.title==null)?sName:ops.title;
		if(type=='[xml]'){
			var myAjax = new Ajax.Request('/xmlhttp.html',{	
										  parameters: 'f='+encodeURI(sName)+'&timespan='+Math.random()+'&'+args ,
										  method: 'get',
										  evalJS: true,
										  onComplete: function(r) {
											TM._dialog_ = _window.Open(r.responseText,title, 'ismodal=1,class=NOKIA,width='+w+',height='+h);
											}});
		}else if(sContent.substring(0,4)=='[id]'){
			TM._dialog_=_window.Open('[id]'+Wid,title, 'ismodal=1,class=NOKIA,width='+w+',height='+h);
		}else{
			TM._dialog_=_window.Open(sContent,title, 'ismodal=1,class=NOKIA,width='+w+',height='+h);
		}
	},
	doSelect : function(flag,fname,value){
		var textArray = this.selectObj.text.value.split(',').without(fname);
		if(flag)textArray.push(fname);
		var valueArray = this.selectObj.value.value.split(',').without(value);
		if(flag)valueArray.push(value);
		this.selectObj.text.value = textArray.join(',');
		this.selectObj.value.value = valueArray.join(',');
	},
	
	/*打开查询窗口*/
	openQuery : function(){
			var Wid = TM.queryDiv;
			var sName = '查询页面'
			var sQuery = TM.getQueryString();
			var ajax = new Ajax.Request('/xmlhttp.html',{
																parameters: 'f='+encodeURI(sName)+'&'+sQuery ,method: 'get',evalJS: true,
																onComplete: function(r) {
																	var w_=_window.Open(r.responseText,'查询','ismodal=1,button=OK|CANCEL,class=NOKIA');
																	w_.OnOK=function(){
																		TM.tQuery(Form.serialize('queryform'));
																		w_.Hidden();
																	}
																	}});
	},
	Select : function(sName,txtId,valueId){
		if(document.readyState=='complete'){
		var tObj,vObj;
		tObj = Object.isString(txtId)?$(txtId):txtId;
		vObj = Object.isString(valueId)?$(valueId):valueId;
		
		if(tObj==null||vObj==null){
			alert('未定义的对象！！');
			return;			
		}
		if(tObj.tagName.toLowerCase()=='input'){
			sQuery = 'objText='+((vObj.value!='')?tObj.value:'')+'&objValue='+vObj.value;
		}else{
			sQuery = 'objText='+((vObj.value!='')?tObj.innerHTML:'')+'&objValue='+vObj.value;
		}
		var title = sName;
		new Ajax.Request('/aspx/xmlhttp.aspx',{parameters: 'f='+encodeURI(sName)+'&'+sQuery ,method: 'get',evalJS: true,onComplete: function(transport) {
			var dialogSelect = _window.Open(transport.responseText,title, 'ismodal=1,button=OK|CANCEL,class=NOKIA,width=420,height=200');
			dialogSelect.OnOK = function(){
				if(tObj.tagName.toLowerCase()=='input'){
					tObj.value = $('selectedText').innerHTML;
				}else{
					tObj.innerHTML=($('selectedText').innerHTML||'选择');
				}
				vObj.value=$('selectedValue').value;
				dialogSelect.Hidden();
			}
			}});
			}else{
				document.onreadystatechange=function(){
					TM.Select(sName,txtId,valueId)
				}
		}
	},
	FileSelect : function(inputObj,ImgObj,title){
		if(document.readyState=='complete'){
			if(Object.isString(inputObj))inputObj = $(inputObj);
			if(Object.isString(ImgObj))ImgObj = $(ImgObj);
			var sFeatures = 'class=NOKIA,button=OK|CANCEL,width=480px,height=400px,resize=0,ismodal=1';
			var sTitle = '选择我的文件';
			var sQuery = 's=' + Math.random();
			new Ajax.Request('/MyFiles.html',{
				asynchronous:false,
				parameters: sQuery,
				method: 'get',
				evalJS: false,
				onSuccess: function(r) {
					TM._FileDialog=_window.Open(r.responseText,title, sFeatures);
					TM._FileDialog.OnOK= function(){
						var objValue = $('imgValue');
						if(objValue!=null){
							if(ImgObj!=null)ImgObj.src =objValue.value
							if(inputObj!=null)inputObj.value =objValue.value
							this.Hidden();
						}else{
							alert('对不起！！你还未选择文件！！\n请重新选择你上传的文件！！！');
						}
					}
				},
				onFailure: function(r){
					if(r.status=='403'){
						alert('您没有上传文件管理的权限！！');
					}else{
						alert(r.status+'['+r.statusText+']');
					}
				}
			});		
		}else{
			document.onreadystatechange=function(){
				TM.FileSelect(inputObj,ImgObj,title)
			}
		}
	},
	UploadFile :function (){
		Element.hide('browser');
		Element.removeClassName('tab-browser','current')
		Element.show('upload')
		Element.addClassName('tab-upload','current')
	},
	BrowserFile : function(sQuery){
		new Ajax.Request('/MyFiles.html',{
					asynchronous:false,
					parameters: 's='+Math.random()+'&'+sQuery,
					method: 'get',
					evalJS: false,
					onSuccess: function(r) {
						TM._FileDialog.SetContent(r.responseText)
					}
				});
		Element.hide('upload');
		Element.removeClassName('tab-upload','current')
		Element.show('browser')
		Element.addClassName('tab-browser','current')
	},

	/*******************************模块功能处理**********************************/
	/*执行多选项命令*/
	doCheckBoxCmd : function(fName,fCb,fVal,balert){
		if(this.CheckIsChecked(fCb)){
			return this.doCmd(fName,fCb+'='+this.getCheckBoxValue(fCb)+'&State='+fVal,balert||false);
		}
	},
	doCheckBoxOpen : function(fName,fCb,fVal){
		if(this.CheckIsChecked(fCb)){
			var q ='f='+encodeURI(fName);
			var myAjax = new Ajax.Request('/xmlhttp.html',{parameters: q ,method: 'get',
																		onComplete: function(r){
																			_window.Open(r.responseText,fName,'ismodal=1');
																		}});
		}
	},
	getCheckBoxValue : function(fId){
		var str ="";
		var obj=document.getElementsByTagName("INPUT");
		for(var i=0;i<obj.length;i++)
			if(obj[i].type=="checkbox")
			{
				if(obj[i].id==fId||obj[i].name==fId)
				{
					if(obj[i].checked&&!obj[i].disabled)
					{
						str = str +  obj[i].value + ",";
					}
				}
			}
		return str;
	},
	/*执行命令*/
	doConfirmCmd : function(/*String*/fCmd,/*String*/fTitle,/*String*/sQuery,/*boolean?*/fIsAlert){
		fTitle = (fTitle==null)?fCmd:fTitle;
		if(!window.confirm('是否确认执行['+fTitle+']？'))
				return false;
		var q = 'f='+encodeURI(fCmd)+'&'+sQuery;
		this.IsAlert = fIsAlert;
		var rtnValue = false;
		var myAjax = new Ajax.Request('/xmlhttp.html',{asynchronous:false,parameters: q ,method: 'get',
																	onComplete:function(r){
																		/*处理返回的数据*/
																		rtnValue =  TM.doResult(r.responseText);
																	}});
		return rtnValue;
	},
	/*执行命令*/
	doCmd : function(/*String*/fCmd,/*String*/sQuery,/*boolean?*/fIsAlert){
		if(fCmd.indexOf('删除')>-1){
			if(!window.confirm('执行['+fCmd+'],将删除数据(不可恢复)？'))
				return false;
		}
		var q = 'f='+encodeURI(fCmd)+'&'+sQuery;
		this.IsAlert = fIsAlert;
		var rtnValue = false;
		var myAjax = new Ajax.Request('/xmlhttp.html',{asynchronous:false,parameters: q ,method: 'get',
																	onComplete:function(r){
																		/*处理返回的数据*/
																		rtnValue =  TM.doResult(r.responseText);
																	}});
		return rtnValue;
	},
	/*处理返回数据*/
	doResult: function(fC){
		if(!fC){alert("提交服务器操作失败,请联系管理员!!!     ");return false;}
		try{
			if(fC.split(",")[0].toString()=='1'||fC.split(",")[0].toString()=='2'){
				var message="操作成功!!!";
				if(fC.split(",").length>1)
					if(fC.split(",")[1].toString().length>0)
						var message=fC.split(",")[1].toString();
				/*是否回显提示*/
				if(this.IsAlert) _window.Alert(message, '提示');
				return true;
			}else if(fC.split(",")[0].toString()=='102'){
				alert('找不到此更新的内容！！！('+fC.split(",")[0]+')');
				return false;
			}else if(fC.split(",")[0].toString()=='103'){
				alert('验证码填写出错，请检查！！！('+fC.split(",")[0]+')');
				return false;
			}else{
				if(fC.split(",").length>1) var message = fC.split(",")[1].toString()
				_window.Alert(message + "("+ fC.split(",")[0].toString() + ")", '提示','resize=no');
				return false;
			}
		}catch(e){alert(e.message);}
		return false;
	},
	/**********************************表单提交处理****************************************/
	saveContentCmd : function(fObj,tForm,isAlert){
		try{
			TM.isAlert = isAlert;
			fObj.disabled=true;
			var d = Form.serialize(tForm);
			
			var myAjax = new Ajax.Request('/aspx/cityflypost.aspx',{
																		asynchronous:false, parameters: d ,method: 'post'});
			fObj.disabled=false;
			return this.returnSaveCmdResult(myAjax);					
		}catch(e){
			alert(e.message);
			fObj.disabled=false;
			return false;
		}
		return false;
	},
		/* 处理 提交数据后返回的代码和消息 */
	returnSaveCmdResult : function(Ajax){
		var r = Ajax.transport;
		if(r.status!=200) {alert(r.statusText);return false;}
		var arr = r.responseText.split(',');
		switch(arr[0])
		{
			case "1":
				if(TM.isAlert) _window.Alert(arr[1],'提示');
				return true;
			case "2":
				if(TM.isAlert) _window.Alert(arr[1],'提示');
				return true;
			default:
				alert(arr[1]);
				break;
		}
		return false;
	},
	/* 增加或更新模块*/
	tUpdate : function(Idx,fId,fDiv,fName,fPage,fPName,fQuery){
		if(Idx==-1){
			this.templates[this.templates.length] = {id:fId,div:fDiv,name:fName,page:fPage,query:fQuery,pName:(fName==fPName)?'':fPName};
			this.activeIndex = this.templates.length-1;
			this.activeItem = fName;
			this.activeDiv = fDiv;
		}else{
			this.activeIndex = Idx;
			if(fId!=null) this.templates[Idx].id = fId;
			if(fDiv!=null) this.templates[Idx].div = fDiv;
			if(fName!=null) this.templates[Idx].name = fName;
			if(fPage!=null&&fPage!=0) this.templates[Idx].page = fPage;
			if(fQuery!=null) this.templates[Idx].query = fQuery;
			//alert(this.templates[Idx].name+'='+fPage + '|page='+this.templates[Idx].page);
			this.activeItem = this.templates[Idx].name;
			this.activeDiv = this.templates[Idx].div;
		}
	},
	reload : function(){
		this.tList();
	},
	doMenuMore : function(obj,fName,arg,h,w){
		var menu = TM.$('popMenu');
		if(menu==null) menu = TM.createDiv('popMenu','menu');
		var q = 'f='+encodeURI(fName)+arg;
		var myAjax= new Ajax.Updater(menu,'/xmlhttp.html',{asynchronous:false,parameters: q ,method: 'get'});
		menu.setAttribute('class','popMenu');
		menu.setAttribute('className','popMenu');
		menu.style.width=(typeof(w)=='number')?w:obj.offsetWidth+8;
		menu.style.left=((TM.getAbsLeft(obj)+menu.offsetWidth)>document.body.clientWidth)?document.body.clientWidth-menu.offsetWidth-10:this.getAbsLeft(obj);
		menu.style.height=(typeof(h)=='number')?h:100;
		menu.style.top=TM.getAbsTop(obj)+obj.offsetHeight;
	},
	tQuery : function(fQuery,QueryText){
		this.templates[this.activeIndex].query = fQuery;
		this.activeQuery = QueryText;
		this.tList(1)
	},
	/* 返回模板的索引值 不存在则返回-1*/
	tIndexOf : function(cName){
		var idx = -1;
		for(var i=0;i<this.templates.length;i++){
			if(this.templates[i].name==cName){
				idx = i;
				break;
			}
		}
		return idx;
	},
	/* 返回上级数据 */
	pList : function(){
		var fName = this.templates[this.activeIndex].pName
		var idx = this.tIndexOf(fName)
		if(idx==-1) return;
		this.closeTab();
		this.openTab(this.templates[idx].name,null,null)
	},
	/* 显示数据 */
	tList : function(cPage,cName,cDiv,Id,subQuery){
		if(typeof(cDiv)=='string'&&this.$(cDiv)!=null) this.activeDiv = cDiv;
		if(typeof(cName)=='string') this.activeIndex = this.tIndexOf(cName);
		this.tUpdate(this.activeIndex,Id,cDiv,cName,cPage,(this.activeItem==cName)?'':this.activeItem,subQuery);
		var _w = null;
		this.closePopup();
		var myAjax = new Ajax.Request('/xmlhttp.html',{
																	parameters: 'f='+encodeURI(this.activeItem)+'&'+TM.getQueryString() ,evalJS: true,method: 'get',
																	onCreate:function(){
																		_w = _window.Open('<img src="/images/default/loading.gif"/>','数据加载中,请稍候...','ismodal=1,width=240,class=NOKIA,resize=no');
																	},
																	onComplete:function(r){
																		_w.Hidden();
																		TM.loadData(r);
																	}});
	},
	getQueryString : function(){
		var idx = this.activeIndex
		if(idx==-1) return;
		//alert('存储:'+this.templates[idx].id);
		var s = 'page=' + this.templates[idx].page ;
		s+= '&id=' + this.templates[idx].id;
		s+= '&'+this.templates[idx].query;
		return s+'&'+Math.random();
	},
	switchContent : function(objid){
		var tags = document.getElementsByTagName("div")
		for(var i=0;i<tags.length;i++){
			if(tags[i].className!='contents'){
				continue;
			}
			if(tags[i].id==objid){
				tags[i].style.display='';
				continue;
			}
			tags[i].style.display='none';
		}
	},
	/* Tab 标签功能使用 */
	closeTab : function(){
		var ulId = 'tabs';
		if(this.activeIndex==0) return;
		var cElement =null;
		var pName = this.templates[this.activeIndex].pName;
		var tags = this.$(ulId).getElementsByTagName('li');
		for(var i = 0 ; i < tags.length; i ++ ){
			if(tags[i].innerHTML==this.activeItem||tags[i].innerHTML==this.activeItem+' ') cElement = tags[i];
		}
		if(cElement!=null&&cElement.rel=='tmp'){
			this.$(ulId).removeChild(cElement);
			var tmp = 'div_'+encodeURI(this.activeItem);
			tmp = this.$(tmp);
			tmp.removeNode(true);
		}
		this.templates.splice(this.activeIndex,1);
		this.switchTab(ulId,pName)
	},
	switchTab : function(ulId,fName){
		fName = (fName.indexOf(' ')>0)?fName.substring(0,fName.indexOf(' ')):fName;
		this.activeItem=fName;
		this.activeIndex = this.tIndexOf(fName);
		this.switchContent(this.templates[this.activeIndex].div)
		var tags = this.$(ulId).getElementsByTagName('li');
		for(var i = 0 ; i < tags.length; i ++ ){
			if((tags[i].innerHTML==fName||tags[i].innerHTML==fName+' ')){
				tags[i].setAttribute('class','current');
				tags[i].setAttribute('className','current');
			}else{
				tags[i].setAttribute('class','');
				tags[i].setAttribute('className','');
			}
		}
	},
	openTab : function(fName,id,query){
		var ulId = 'tabs';
		var RandNum = parseInt(100*Math.random());
		var divid = 'div_'+encodeURI(fName);
		fName = (fName.indexOf(' ')>0)?fName.substring(0,fName.indexOf(' ')):fName;
		if(this.IsEdit){
			if(!window.confirm("重新加载页面,您是否确定？       ")){
				return;
			}
		}
		var el = null;
		var cElement = null;
		var tags = this.$(ulId).getElementsByTagName('li');
		for(var i = 0 ; i < tags.length; i ++ ){
			if((tags[i].innerHTML==fName||tags[i].innerHTML==fName+' ')){
				el = tags[i];
				el.setAttribute('class','current');
				el.setAttribute('className','current');
			}else{
				tags[i].setAttribute('class','');
				tags[i].setAttribute('className','');
			}
			//if(tags[i].innerHTML==this.activeItem||tags[i].innerHTML==this.activeItem+' ') cElement = tags[i];
		}
		if(el==null){
			el = this.createLi(id,this.$('Last'),fName,'TM.switchTab(\''+ulId+'\',\''+fName+'\')','TM.closeTab()');
			this.createDiv(divid,'contents');
		}
		/*层未被创建,则指向主层 divContent*/
		divid = (this.$(divid)==null)?'divContent':divid;
		this.tList(null,fName,divid,id,query);
	},
	/* 动态加载数据使用 */
	loadData :function(r){
		fC = r.responseText
		TM.switchContent(TM.activeDiv);
		TM.setInnerHTML(TM.activeDiv,fC);
		if(TM.$('queryString_'+TM.templates[TM.activeIndex].name)!=null) if(TM.templates[TM.activeIndex].query!=null) TM.$('queryString_'+TM.templates[TM.activeIndex].name).innerHTML = TM.templates[TM.activeIndex].query;
	},
	doCheckedCode : function(vCode){
		if(typeof(vCode)=="string") vCode = TM.$(vCode);
		if(vCode.value.length==6){
			TM.IsCheckedCode=1;
			TM.CheckCode = vCode.value;
			return true;
		}
		alert('请填写右边图片中6位验证码');
		vCode.focus();
		TM.IsCheckedCode = 0;
		TM.CheckCode = ''
		return false;
	},
	/**************************加载临时数据***********************************/
	openWin : function(objId,fName,fQuery,w,h){
		this.tmpDiv = objId;
		this.XmlGetData(fName,fQuery,TM.loadDataForTmp);
	},
	loadTheContent : function(objId,fName,fQuery){
		if(TM.$(objId)==null){if(debug) alert('请选定义div['+objId+']');return;}
		this.tmpDiv = objId;
		this.setXmlHttpMode(102);
		this.XmlGetData(fName,fQuery,this.loadTempData);
		this.setXmlHttpMode(100);
	},
	clearTmpBg : function(){
		if(xPage.$('tmp_bg')!=null){xPage.$('tmp_bg').style.display='none';}
	},
	initTmpBg : function(msg){
		var bgDiv = TM.$('tmp_bg');
		var obj = TM.$(this.tmpDiv);
		if(bgDiv==null){
			var bgDiv = document.createElement( "div" );
			bgDiv.id  = 'tmp_bg';
			bgDiv.style.position="absolute";
			bgDiv.style.backgroundColor="#eee";
			document.body.insertAdjacentElement("beforeEnd",bgDiv);
		}
		bgDiv.style.width  =obj.offsetWidth;
		bgDiv.style.height =obj.offsetHeight;//screen.availHeight;
		bgDiv.style.zIndex = 1000;
		bgDiv.style.filter ="alpha(opacity=30)";
		bgDiv.style.left = this.getAbsoluteLeft(obj);
		bgDiv.style.top = this.getAbsoluteTop(obj);
		bgDiv.style.display="";
		bgDiv.innerHTML=msg;
	},
	loadDataForTmp : function(fC){
		xWin.popWin(TM.tmpDiv,TM.tmpWidth,TM.tmpHeight,'提示窗口',fC);
	},
	loadTempData : function(fC){
		TM.$(TM.tmpDiv).innerHTML = fC;
	},
	/**************************结束***********************************/
	/* 动态加载数据使用 */
	loadDataForQuery :function(fC){
		xWin.popWin(TM.tmpDiv,TM.tmpWidth,TM.tmpHeight,TM.activeItem + '查询：',fC);
	},
	/*************************页面通用功能部分************************/
	/* 复选框 全选 / 取消 /反选*/
	CheckBoxSelect : function(fId,flag)
	{
		var obj=document.getElementsByTagName("INPUT");
		for(var i=0;i<obj.length;i++)
			if(obj[i].type=="checkbox"&&!obj[i].disabled)
			{
				if((!fId)||obj[i].id==fId||obj[i].name==fId){
					if(flag==2)
					{
						obj[i].checked=!obj[i].checked;
					}else{
						obj[i].checked=flag;
					}
					if(obj[i].onclick && obj[i].onclick.toString().indexOf("CheckBoxSetColor")!=-1)
					{
						CheckBoxSetColor(obj[i]);
					}
				}
			}
	},
	swithClass : function(thisEl,comClass,curClass){
		var els = thisEl.parentNode.childNodes;
		for(var i=0 ;i<els.length;i++){
			el = els[i];
			if(el.className!=comClass&&el.className!=curClass)
			continue;
			if(el==thisEl)
			{
				el.className=curClass
				continue;
			}
			if(el.className==curClass)
			{
				el.className=comClass
				continue;
			}
		}
	},
	loadOptions : function(fnTargetObj,fnParentObj,fName,fuseDefault){
		if(fnTargetObj==null)return ;
		fnTargetObj.disabled = true;
		var u = fnTargetObj.onchange;
		var id = fnTargetObj.id;
		var str = '<select id="'
		+fnTargetObj.id
		+'" name="'
		+fnTargetObj.name
		+'" size="'
		+fnTargetObj.size
		+'" onchange="'
		+fnTargetObj.onchange 		
		+'" class="'
		+fnTargetObj.className
		+'">'
		fuseDefault = (fuseDefault==null)?1:fuseDefault;
		if(fuseDefault==1){
			str+='<option value="">'
			+fnTargetObj.options(0).text
			+'</option>'
		}
		str+=this.XmlGetDataEx(fName,'&PID='+fnParentObj.value)
		+'</select>';
		fnTargetObj.outerHTML = str;
		Gel(id).onchange = u
		fnTargetObj.disabled = false;
	},
	loadCatalog : function(fnTargetObj,fnParentObj,fuseDefault){
		this.loadOptions((typeof(fnTargetObj)=='object')?fnTargetObj:TM.$(fnTargetObj),(typeof(fnParentObj)=='object')?fnParentObj:TM.$(fnParentObj),'分类目录选择',(fuseDefault==null)?0:fuseDefault);
	},
	setValue : function(objid,objvalue){
		if(TM.$(objid)==null) return;
		TM.$(objid).value = objvalue;
	},
	selectOptions : function(){
		if(arguments.length<3) return;
		var tObj = (typeof(arguments[0])=='string')?this.$(arguments[0]):arguments[0]; //第一个参数为目录对象
		var iMax = arguments[arguments.length-1] //最后一个参数为最大可选择项
		if(tObj.options.length>=iMax){
			popAlert('<font class="Err">对不起!!你只能选择'+iMax+'项!!</font>','警告');
			return ;
		}
		var s = '',v = '';
		for(var i=1;i<arguments.length-1;i++)
		{
			var obj = (typeof(arguments[i])=='string')?this.$(arguments[i]):arguments[i];
			if(obj.selectedIndex > -1 ){
				s += obj.options[obj.selectedIndex].text + ' /';
				v = obj.options[obj.selectedIndex].value;
			}
		}
		if(s.lastIndexOf('/')>-1) s = s.substring(0,s.length-2);
		if(s.length>0){
			var oOption = new Option(s,v);
			tObj.options.add(oOption,-1);
		}
	},
	removeOptions : function(){
		for(var i=0;i<arguments.length;i++)
		{
			if(arguments[i].selectedIndex > -1){
				arguments[i].options[arguments[i].selectedIndex] ==null;
				arguments[i].removeChild(arguments[i].options[arguments[i].selectedIndex]);
			}
		}
	},
	/**取得objid对象的Text 和value ,传给textobjid,和valueobjid*/
	getOptionValues : function(objid,textobjid,valueobjid,flag){
		flag = (flag==null)?false:flag;
		var obj = this.$(objid);
		if(obj==null){if(debug)alert("对不起,对象["+objid+"]未建立");return}
		var text='';
		var values='';
		for(var i=0;i<obj.options.length;i++){
			if(flag){
				text+=","+obj.options[i].text.replace(",","");
				values+=","+obj.options[i].value.replace(",","");
			}else if(obj.selectedIndex>-1){
				text=obj.options[i].text;
				values=obj.options[i].value;
				break;
			}
		}
		this.setTagValue(textobjid,text);
		this.setTagValue(valueobjid,values);
	},
	/*是否有选定选项 Key 为name属性*/
	CheckIsChecked : function(Key){
		var obj	=document.getElementsByName(Key);
		for(var i=0;i<obj.length;i++)
			if(obj[i].checked&&!obj[i].disabled)
				return true;
		window.alert("请至少选择一个");
		return false;
	},
	/*检查CHECKBOX的选择数量,objid ID值,maxNum 最大数量*/
	chkCheckBox : function(objid,maxNum){
		if(maxNum==null) maxNum = this.MaxSelected;
		var els = document.getElementsByTagName("INPUT");
		var count = 0 ;
		for(var i=0;i<els.length;i++)
			if(els[i].type=="checkbox"&&els[i].id==objid){
				if(els[i].checked) count++;
				if(count>maxNum) return false;
			}
		return true;
	},
	doHidden : function(){
		var lens = arguments.length;
		if(typeof(arguments[arguments.length-1])=='boolean'){
			var YesNo = arguments[arguments.length-1];
			lens = arguments.length-1;
		};

		for(var i=0;i<lens;i++){
			var divObj = this.$(arguments[i]);
			if(divObj!=null){
				if(lens == arguments.length-1)
				divObj.style.display = (YesNo)?'':'none'
				else
				divObj.style.display = (divObj.style.display!='none')?'none':'';
			}
		}
	},
	/* 对象创建 */
	createDiv : function(objid,rel,insertobj){
		 var div = document.createElement("div");
		 div.id = objid;
		 div.setAttribute('class',rel);
		 div.setAttribute('className',rel);
		 if(insertobj==null){
		 	TM.$('divContent').insertAdjacentElement("afterEnd",div);
			 }else
		 	insertobj.insertAdjacentElement("afterEnd",div);
		 return div;
	},
	createLi : function(id,ghost,txt,fn,fndbclick){
		var li=document.createElement('li');
		li.relid = id;
		li.setAttribute('class','current');
		li.setAttribute('className','current');
		li.title = txt + '('+id+')';
		li.innerHTML = txt;
		li.rel = "tmp";
		li.onclick=function(){eval(fn);}
		if(fndbclick!=null){li.ondblclick=function(){eval(fndbclick);};li.title=li.title+'[双击关闭标签]'}
		ghost.insertAdjacentElement("beforeBegin",li);
		return li;
	},

	/* 代替InnerHTML属性设定的函数*/
	setInnerHTML : function (elid, htmlCode) {
		var el = (typeof(elid)=="object")?elid:TM.$(elid);
		var ua = navigator.userAgent.toLowerCase();
		if (ua.indexOf('msie') >= 0 && ua.indexOf('opera') < 0) {
			htmlCode = '<div style="display:none">for IE</div>' + htmlCode;
			htmlCode = htmlCode.replace(/<script([^>]*)>/gi,
										'<script$1 defer>');
			el.innerHTML = '';
			el.innerHTML = htmlCode;
			el.removeChild(el.firstChild);
		} else {
			var el_next = el.nextSibling;
			var el_parent = el.parentNode;
			el_parent.removeChild(el);
			el.innerHTML = htmlCode;
			if (el_next) {
				el_parent.insertBefore(el, el_next)
			} else {
				el_parent.appendChild(el);
			}
		}
	},
	/****取得对象绝对坐标*****/
	getAbsLeft : function(ob){
		if(!ob){return null;}
		  var obj = ob;
		  var objLeft = obj .offsetLeft;
		  while( obj != null && obj .offsetParent != null && obj .offsetParent.tagName != "BODY" ){
			objLeft += obj .offsetParent.offsetLeft;
			obj = obj .offsetParent;
		  }
		return objLeft ;
	},
	getAbsTop : function(ob){
		if(!ob){return null;}
		var obj = ob;
		var objTop = obj .offsetTop;
		while( obj != null && obj .offsetParent != null && obj .offsetParent.tagName != "BODY" ){
		  objTop += obj .offsetParent.offsetTop;
		  obj = obj .offsetParent;
		}
		return objTop ;
	},
	openHtmlEditor : function(fnId){
		this.oFCKeditor = new FCKeditor(fnId,"100%","320"); 
		this.oFCKeditor.ReplaceTextarea();
		return;
	},
	GetContents : function(fnId){
		if(typeof(FCKeditorAPI)=='undefined'||FCKeditorAPI==null) return ;
		oEditor = FCKeditorAPI.GetInstance(fnId) ;
		if(oEditor)	TM.$(fnId).value = oEditor.GetXHTML(true);
	},
	/* 取得对象 */
	$ : function(id){
		if(document.getElementById(id)==null){
			//if(debug) alert('请先定义对象['+id+'].   ');
			return null;
		}
		return document.getElementById(id);
	}
}

function loadTempData(fC){
	TM.$(tmpDiv).innerHTML = fC;
}
document.onclick = TM.onClick;


/*-----------------以下为_Window 对象----------------*/
function _window(features)
{
	this.id=this.name="_W_"+(++_window.wIndex);
	this.string="_window.windows."+this.id;
	this.zIndex=++_window.zIndex;
	this.className=_window.getFeature(features,"class")||_window.ClassName;
	this.bodyWidth=parseInt(_window.getFeature(features,"width"))||_window.Width;
	this.bodyHeight=parseInt(_window.getFeature(features,"height"))||_window.Height;
	this.left=_window.getFeature(features,"left");
	this.top=_window.getFeature(features,"top");
	this.right=_window.getFeature(features,"right");
	this.bottom=_window.getFeature(features,"bottom");
	this.move=_window.getFeature(features,"move").toLowerCase()||"move";
	this.isModal=_window.getFeature(features,"ismodal")?true:false; //独立
	this.button=_window.getFeature(features,"button").toUpperCase();
	this.resize=_window.getFeature(features,"resize").toLowerCase()||"resize";
	this.buttons={};
	_window.windows[this.id]=this;
}

_window.Version="Fonshen JS Window V1.00.08.01.03";
_window.ClassName="NOKIA";
_window.Width=400;
_window.Height=-1;
_window.Timer=10;
_window.windows={};
_window.wIndex=0;
_window.zIndex=0;
_window.clientWidth=0;
_window.clientHeight=0;
_window.onmousemove=null;
_window.onmouseup=null;
_window.onselectstart=null;

_window.getFeature=function(source,name)
{
	var reg=new RegExp("(^|,|\\s)"+ name +"\\s*=\\s*([^,]*)(\\s|,|$)","i");
	if (reg.test(source)) return RegExp.$2;
	return "";
};
_window.getMaxNumber=function()
{
	var num=0;
	for(var i=0;i<arguments.length;i++) if(arguments[i]>num) num=arguments[i];
	return num;
};

_window.Open=function(content,title,features)
{
	var obj=new _window(features);
	obj.Creat(content,title);
	return obj;
};
_window.Alert=function(content,title,features)
{
	var obj=new _window(features);
	obj.button="OK";
	obj.isModal = true;
	obj.Creat(content,title||"Alert");
	obj.buttons["OK"].focus();
	return obj;
};
_window.Confirm=function(content,title,features)
{
	var obj=new _window(features);
	obj.button="OK|CANCEL";
	obj.isModal = true;
	obj.Creat(content,title||"Confirm");
	obj.buttons["OK"].focus();
	return obj;
};

_window.prototype.Creat=function(content,title)
{
	if(this.isModal)
	{
		this.modal=document.createElement("div");
		this.modal.className="MODAL";
		this.modal.style.position="absolute";
		this.modal.style.zIndex=this.zIndex;
		this.modal.style.width=document.documentElement.scrollWidth+"px";
		this.modal.style.height=document.documentElement.scrollHeight+"px";
		this.modal.style.left="0px";
		this.modal.style.top="0px";
		document.body.appendChild(this.modal);
		this.zIndex=++_window.zIndex;
	}
	this.board=document.createElement("div");
	this.board.className=this.className;
	this.board.style.position="absolute";
	this.board.style.zIndex=this.zIndex;
	this.board.style.visibility="hidden";
	document.body.appendChild(this.board);

	if(!_window.clientHeight)
	{
		this.board.style.left = "100%";
		this.board.style.top = "100%";
		_window.clientWidth = this.board.offsetLeft;
		_window.clientHeight = this.board.offsetTop;
	}
	var styles=new Array("LEFT_TOP","TOP","RIGHT_TOP","RIGHT","RIGHT_BOTTOM","BOTTOM","LEFT_BOTTOM","LEFT","CONTENT","TITLE");
	this.sides=new Array();
	if(this.button)
	{
		styles[4]="RIGHT_BOTTOM_BY_BUTTON";
		styles[5]="BOTTOM_BY_BUTTON";
		styles[6]="LEFT_BOTTOM_BY_BUTTON";
		styles[styles.length]="BUTTON";
	}
	if(this.resize!="no") styles[styles.length]="RESIZE";
	styles[styles.length]="CLOSE";
	var sAttachFocus="obj.onmousedown=function(e){ "+this.string+".Focus();};";
	var sAttachPreMove=this.move=="no"?sAttachFocus:"obj.onmousedown=function(e){ "+this.string+".PreMove(e?e:window.event);};";
	for(var i=0;i<styles.length;i++)
	{
		var obj=document.createElement("div");
		obj.className=styles[i];
		obj.style.position="absolute";
		this.board.appendChild(obj);
		switch(styles[i])
		{
			case "CONTENT":
				this.contentCase=obj;
				obj.style.width=this.bodyWidth+"px";
				this.SetContent(content);
				obj.style.height=this.bodyHeight+"px";
				obj.style.left=(this.sides[7].width+obj.offsetLeft)+"px";
				obj.style.top=(this.sides[1].height+obj.offsetTop)+"px";
				eval(sAttachFocus);
				this.width=this.bodyWidth+this.sides[3].width+this.sides[7].width;
				this.height=this.bodyHeight+this.sides[1].height+this.sides[5].height;
				this.board.style.height=this.height+"px";
				this.board.style.width=this.width+"px";
				this.minWidth=_window.getMaxNumber(this.sides[0].width+this.sides[2].width,this.sides[3].width+this.sides[7].width,this.sides[4].width+this.sides[6].width)+20;
				this.minHeight=_window.getMaxNumber(this.sides[0].height+this.sides[6].height,this.sides[1].height+this.sides[5].height,this.sides[2].height+this.sides[4].height)+2;
				break;

			case "TITLE":
				this.titleCase=obj;
				obj.style.width=this.width+"px";
				this.titleCase.dx=obj.offsetWidth-this.width;
				if(this.minWidth<this.titleCase.dx) this.minWidth=this.titleCase.dx;
				if(this.width>this.titleCase.dx) obj.style.width=(this.width-this.titleCase.dx)+"px";
				this.SetTitle(title);
				eval(sAttachPreMove);
				break;

			case "BUTTON":
				this.buttonCase=obj;
				obj.style.width=this.width+"px";
				obj.style.bottom="0px";
				this.buttonCase.dx=obj.offsetWidth-this.width;
				if(this.minWidth<this.buttonCase.dx) this.minWidth=this.buttonCase.dx;
				if(this.width>this.buttonCase.dx) obj.style.width=(this.width-this.buttonCase.dx)+"px";
				var buttons=this.button.split("|");
				for(var j=0;j<buttons.length;j++)
				{
					var o=document.createElement("button");
					o.className=buttons[j];
					o.title=buttons[j];
					obj.appendChild(o);
					eval("o.onclick=function(e){ "+this.string+".On"+buttons[j]+"();};");
					this.buttons[buttons[j]]=o;
				}
				break;

			case "RESIZE":
				obj.style.cursor="se-resize";
				eval("obj.onmousedown=function(e){ "+this.string+".PreResize(e?e:window.event);};");
				break;

			case "CLOSE":
				eval("obj.onclick=function(e){ "+this.string+".Close();};");
				break;

			default:
				this.sides[i]=obj;
				this.sides[i].width=obj.offsetWidth;
				this.sides[i].height=obj.offsetHeight;
				eval(sAttachPreMove);
				break;
		}
	}
	this.sides[1].dx=this.sides[0].width+this.sides[2].width;
	if(this.width>this.sides[1].dx) this.sides[1].style.width=(this.width-this.sides[1].dx)+"px";
	this.sides[3].dy=this.sides[2].height+this.sides[4].height;
	if(this.height>this.sides[3].dy) this.sides[3].style.height=(this.height-this.sides[3].dy)+"px";
	this.sides[5].dx=this.sides[4].width+this.sides[6].width;
	if(this.width>this.sides[5].dx) this.sides[5].style.width=(this.width-this.sides[5].dx)+"px";
	this.sides[7].dy=this.sides[6].height+this.sides[0].height;
	if(this.height>this.sides[7].dy) this.sides[7].style.height=(this.height-this.sides[7].dy)+"px";

	this.sides[0].style.left="0px";
	this.sides[0].style.top="0px";
	this.sides[1].style.left=this.sides[0].width+"px";
	this.sides[1].style.top="0px";
	this.sides[2].style.right="0px";
	this.sides[2].style.top="0px";
	this.sides[3].style.right="0px";
	this.sides[3].style.top=this.sides[2].height+"px";
	this.sides[4].style.right="0px";
	this.sides[4].style.bottom="0px";
	this.sides[5].style.left=this.sides[6].width+"px";
	this.sides[5].style.bottom="0px";
	this.sides[6].style.left="0px";
	this.sides[6].style.bottom="0px";
	this.sides[7].style.left="0px";
	this.sides[7].style.top=this.sides[0].height+"px";

	this.left=this.left?parseInt(this.left):(this.right?_window.clientWidth-this.width-parseInt(this.right):parseInt((_window.clientWidth-this.width)/2));
	this.top=this.top?parseInt(this.top):(this.bottom?_window.clientHeight-this.height-parseInt(this.bottom):parseInt((_window.clientHeight-this.height)/2));
	if(this.left<0) this.left=0;
	if(this.top<0) this.top=0;
	this.left+=document.documentElement.scrollLeft;
	this.top+=document.documentElement.scrollTop;
	this.board.style.left=this.left+"px";
	this.board.style.top=this.top+"px";
	this.board.style.visibility="visible";
	this.status=1;
};

_window.prototype.SetContent=function(content)
{
	var type=content.slice(0,5),tent=content.slice(5);
	if(this.oldcase)
	{
		this.oldcase.appendChild(this.oldcontent);
		this.oldcase = null;
	}
	if(type=="[xml]")
	{
		var myAjax = new Ajax.Updater(this.contentCase,'/xmlhttp.html?timespan='+Math.random()+'&f='+encodeURI(tent), {method: 'get'});
	}
	else if(type=="[url]")
	{
		if(this.iframe)
		{
			if(this.contentCase.firstChild!=this.iframe) this.contentCase.replaceChild(this.iframe,this.contentCase.firstChild);
			this.iframe.src=tent;
		}
		else
		{
			var str=(this.bodyHeight<0)?"onload=\"if("+this.string+".bh<2)"+this.string+".ResizeBy(0,frames[frames.length-1].document.documentElement.scrollHeight);\"":"";
			var id="_F"+this.id;
			this.contentCase.innerHTML="<iframe id=\""+id+"\" name=\""+id+"\" "+str+" onfocus=\""+this.string+".Focus()\"  frameBorder='0' marginHeight='0' marginWidth='0' width='100%' height='100%'></iframe>";
			if(this.bodyHeight<0) this.bodyHeight=1;
			this.iframe=document.getElementById(id);
			this.iframe.src = tent;
			this.frame=eval(id);
		}
	}
	else
	{
		if(this.form)
		{
			if(this.contentCase.firstChild!=this.form) this.contentCase.replaceChild(this.form,this.contentCase.firstChild);
		}
		else
		{
			this.form=document.createElement("div");
			this.form.className="FORM";
			this.form.method="post";
			eval("this.form.onsubmit=function(e){ return false;}");
			if(this.contentCase.hasChildNodes())this.contentCase.replaceChild(this.form,this.contentCase.firstChild);
			else this.contentCase.appendChild(this.form);
		}
		if(type=="[obj]"||content.slice(0,4)=="[id]")
		{
			if(type=="[obj]")this.oldcontent=eval(tent);
			else this.oldcontent=document.getElementById(content.slice(4));
			this.oldcontent.style.display='';//修正Style.Display 的值　By Leo
			this.oldcase=this.oldcontent.parentNode;
			this.form.appendChild(this.oldcontent);
		}
		else
		{
			Element.Methods.update(this.form,content);
		}
		if(this.bodyHeight<0) this.bodyHeight=this.contentCase.offsetHeight+1;
		this.contentCase.style.overflow="auto";
	}
	this.content=content;
};
_window.prototype.SetTitle=function(title)
{
	title=title||"选择Window";
	if(this.title==title) return false;
	this.titleCase.innerHTML=title;
	this.title=title;
};

_window.prototype.Focus=function()
{
	if(this.zIndex<_window.zIndex) this.board.style.zIndex=this.zIndex=++_window.zIndex;
};
_window.prototype.Close=function()
{
	this.Hidden();
	delete _window.windows[this.id];
	for(var key in this) delete this[key];
};
_window.prototype.Hidden=function()
{
	if (typeof(this.MoveTimer)!="undefined") clearTimeout(this.MoveTimer);
	if (typeof(this.ResizeTimer)!="undefined") clearTimeout(this.ResizeTimer);
	document.body.removeChild(this.board);
	if(this.isModal) document.body.removeChild(this.modal);
	if(this.oldcase) this.oldcase.appendChild(this.oldcontent);
	if(this.oldcontent) this.oldcontent.style.display='none';//修订隐藏后不显示 By Leo
	this.status=0;
};
_window.prototype.Show=function()
{
	if(this.oldcase) this.form.appendChild(this.oldcontent);
	if(this.isModal) document.body.appendChild(this.modal);
	document.body.appendChild(this.board);
	this.status=1;
};

_window.prototype.Duplicate=function()
{
	this.copy=document.createElement("DIV");
	document.body.appendChild(this.copy);
	this.copy.style.cssText="position:absolute;left:"+(this.left-2)+"px;top:"+(this.top-2)+"px;width:"+this.width+"px;height:"+this.height+"px;border:2px dotted #000000;";
	this.copy.style.zIndex=this.zIndex+1;
};
_window.prototype.DetachEvent=function(e)
{
	document.body.style.cursor="default";
	document.onmousemove=_window.onmousemove;
	document.onmouseup=_window.onmouseup;
	document.onselectstart=_window.onselectstart;
	if(this.board.releaseCapture) this.board.releaseCapture();
};
_window.prototype.AttachEvent=function(e)
{
	_window.onmousemove=document.onmousemove;
	_window.onmouseup=document.onmouseup;
	_window.onselectstart=document.onselectstart;
	if(e.preventDefault) e.preventDefault();
	else
	{
		document.onselectstart=function(){return false;};
		if(this.board.setCapture) this.board.setCapture();
	}
};

_window.prototype.PreResize=function(e)
{
	if (typeof(this.ResizeTimer)!="undefined") clearTimeout(this.ResizeTimer);
	this.Focus();
	this.Duplicate();
	this.resizeX=e.clientX-this.width-4;
	this.resizeY=e.clientY-this.height-4;
	document.body.style.cursor="se-resize";
	this.AttachEvent(e);
	eval("document.onmousemove=function(e){"+this.string+".Resize(e?e:window.event);};");
	eval("document.onmouseup=function(e){"+this.string+".Resized(e?e:window.event);};");
};
_window.prototype.Resize=function(e)
{
	if(this.resize!="resize-y")
	{
		var w=e.clientX-this.resizeX;
		if(w >= this.minWidth) this.copy.style.width=w+"px";
	}
	if(this.resize!="resize-x")
	{
		var h=e.clientY-this.resizeY;
		if(h >= this.minHeight) this.copy.style.height=h+"px";
	}
};
_window.prototype.Resized=function(e)
{
	this.DetachEvent(e);
	var dx=0,dy=0;
	if(this.resize!="resize-y")
	{
		var w=e.clientX-this.resizeX-4;
		w=(w>this.minWidth)?w:this.minWidth;
		dx=w-this.width;
	}
	if(this.resize!="resize-x")
	{
		var h=e.clientY-this.resizeY-4;
		var h=(h>this.minHeight)?h:this.minHeight;
		dy=h-this.height;
	}
	if(_window.Timer>0&&this.width >= this.minWidth&&this.height >= this.minHeight) this.ActResizeBy(dx,dy);
	else  this.ResizeBy(dx,dy);
	document.body.removeChild(this.copy);
	this.copy=null;
};
_window.prototype.ResizeBy=function(dx,dy)
{
	if(dx)
	{
		this.width+=dx;
		this.board.style.width=this.width+"px";
		this.sides[1].style.width=(this.width-this.sides[1].dx)+"px";
		this.sides[5].style.width=(this.width-this.sides[5].dx)+"px";
		this.titleCase.style.width=(this.width-this.titleCase.dx)+"px";
		if(this.buttonCase) this.buttonCase.style.width=(this.width-this.buttonCase.dx)+"px";
		this.bodyWidth+=dx;
		this.contentCase.style.width=this.bodyWidth+"px";
	}
	if(dy){this.height+=dy;
	this.board.style.height=this.height+"px";
	this.sides[3].style.height=(this.height-this.sides[3].dy)+"px";
	this.sides[7].style.height=(this.height-this.sides[7].dy)+"px";
	this.bodyHeight+=dy;
	this.contentCase.style.height=this.bodyHeight+"px";
	}
};
_window.prototype.ActResizeBy=function(dx,dy)
{
	if(dx||dy)
	{
		var x=dx/10;
		x=(x>0)?Math.ceil(x):Math.floor(x);
		var y=dy/10;
		y=(y>0)?Math.ceil(y):Math.floor(y);
		this.ResizeBy(x,y);
		dx-=x;
		dy-=y;
		this.ResizeTimer=window.setTimeout(this.string+".ActResizeBy("+dx+","+dy+")",_window.Timer);
	}
};

_window.prototype.PreMove=function(e)
{
	if (typeof(this.MoveTimer)!="undefined") clearTimeout(this.MoveTimer);
	this.Focus();
	this.Duplicate();
	this.moveX=e.clientX-this.left+2;
	this.moveY=e.clientY-this.top+2;
	document.body.style.cursor="move";
	this.AttachEvent(e);
	eval("document.onmousemove=function(e){"+this.string+".Move(e?e:window.event);};");
	eval("document.onmouseup=function(e){"+this.string+".Moved(e?e:window.event);};");
};
_window.prototype.Move=function(e)
{
	if(this.move!="move-y") this.copy.style.left=(e.clientX-this.moveX)+"px";
	if(this.move!="move-x") this.copy.style.top=(e.clientY-this.moveY)+"px";
};
_window.prototype.Moved=function(e)
{
	this.DetachEvent(e);
	var tx=(this.move=="move-y")?null:(e.clientX-this.moveX+2);
	var ty=(this.move=="move-x")?null:(e.clientY-this.moveY+2);
	if(_window.Timer>0) this.ActMoveTo(tx,ty);
	else  this.MoveTo(tx,ty);
	document.body.removeChild(this.copy);
	this.copy=null;
};
_window.prototype.MoveTo=function(tx,ty)
{
	if(tx!=null)
	{
		this.left=tx;
		this.board.style.left=tx+"px";
	}
	if(ty!=null)
	{
		this.top=ty;
		this.board.style.top=ty+"px";
	}
};
_window.prototype.ActMoveTo=function(tx,ty)
{
	if((tx==null||tx==this.left)&&(ty==null||ty==this.top)) return;
	if(tx!=null)
	{
		var dx=(tx-this.left)/10;
		dx=(dx>0)?Math.ceil(dx):Math.floor(dx);
		this.left+=dx;
		}if(ty!=null){var dy=(ty-this.top)/10;
		dy=(dy>0)?Math.ceil(dy):Math.floor(dy);
		this.top+=dy;
	}
	this.MoveTo(this.left,this.top);
	this.MoveTimer=window.setTimeout(this.string+".ActMoveTo("+tx+","+ty+")",_window.Timer);
};

_window.prototype.DisableButton=function(name,style)
{
	name=name.toUpperCase();
	this.buttons[name].disabled=true;
	this.buttons[name].className=(style?style:"DISABLED")+" "+name;
};
_window.prototype.EnableButton=function(name)
{
	name=name.toUpperCase();
	this.buttons[name].disabled=false;
	this.buttons[name].className=name;
};

_window.prototype.OnBACK=function()
{
	if(!this.step) this.step=0;
	if(this.OnBACKS){ if(this.step>0) this.OnBACKS[--this.step]();}
};
_window.prototype.OnNEXT=function()
{
	if(!this.step) this.step=0;
	if(this.OnNEXTS){ if(this.step<this.OnNEXTS.length) this.OnNEXTS[this.step++]();}
};
_window.prototype.OnOK=function()
{
	this.Close();
};
_window.prototype.OnCANCEL=function()
{
	this.Close();
};